package com.AAL.Action;

import java.util.List;
import java.util.Map;



import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;
import javax.servlet.http.HttpServletRequest;

import com.AAL.DAO.PurchaseInvoiceDAO;
import com.AAL.DAO.PurchaseInvoiceDetailDAO;
import com.AAL.Model.PurchaseInvoice;
import com.AAL.Model.PurchaseInvoiceDetail;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/*
 * Loc DV
 * Create date:30.3.2011
 */
public class PurchaseInvoiceDetailAction extends ActionSupport implements
		SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private PurchaseInvoiceDetail purchaseInvoiceDetail;
	private PurchaseInvoiceDAO lnkPurchaseInvoice;
	private PurchaseInvoiceDetailDAO lnkPurchaseInvoiceDetail;
	private List<PurchaseInvoiceDetail> lstPurchaseInvoiceDetail;
	private List<PurchaseInvoice> lstPurchaseInvoice;
	private PurchaseInvoice purchaseInvoice;



	public PurchaseInvoiceDetailAction()
	{
		this.purchaseInvoice=new PurchaseInvoice();
		this.purchaseInvoiceDetail=new PurchaseInvoiceDetail();
		this.lnkPurchaseInvoiceDetail=new PurchaseInvoiceDetailDAO();
		this.lnkPurchaseInvoice=new PurchaseInvoiceDAO();
	
		
	}
	
	/*
	 * 
	 * View detail PurchaseInvoice
	 */
	public String detailPurchaseInvoice()
	{
		
		HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
		try{
		
			String purchaseInvoiceID = request.getParameter("purchaseInvoiceID");
			System.out.println(purchaseInvoiceID);
			this.lstPurchaseInvoiceDetail=this.lnkPurchaseInvoiceDetail.getLstPurchaseInvoiceDetailsByPurchaseInvoice(purchaseInvoiceID);
			this.purchaseInvoice=this.lnkPurchaseInvoice.getPurchaseInvoice(purchaseInvoiceID);
			}
		catch (Exception e) {
			// TODO: handle exception
			return ERROR;
		}
		
		return SUCCESS;
		
	}
	
	public String execute() {

		return SUCCESS;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub

	}

	public PurchaseInvoiceDetail getPurchaseInvoiceDetail() {
		return purchaseInvoiceDetail;
	}

	public void setPurchaseInvoiceDetail(PurchaseInvoiceDetail purchaseInvoiceDetail) {
		this.purchaseInvoiceDetail = purchaseInvoiceDetail;
	}

	public PurchaseInvoiceDetailDAO getLnkPurchaseInvoiceDetail() {
		return lnkPurchaseInvoiceDetail;
	}

	public void setLnkPurchaseInvoiceDetail(
			PurchaseInvoiceDetailDAO lnkPurchaseInvoiceDetail) {
		this.lnkPurchaseInvoiceDetail = lnkPurchaseInvoiceDetail;
	}

	public List<PurchaseInvoiceDetail> getLstPurchaseInvoiceDetail() {
		return lstPurchaseInvoiceDetail;
	}

	public void setLstPurchaseInvoiceDetail(
			List<PurchaseInvoiceDetail> lstPurchaseInvoiceDetail) {
		this.lstPurchaseInvoiceDetail = lstPurchaseInvoiceDetail;
	}

	public List<PurchaseInvoice> getLstPurchaseInvoice() {
		return lstPurchaseInvoice;
	}

	public void setLstPurchaseInvoice(List<PurchaseInvoice> lstPurchaseInvoice) {
		this.lstPurchaseInvoice = lstPurchaseInvoice;
	}
	public PurchaseInvoiceDAO getLnkPurchaseInvoice() {
		return lnkPurchaseInvoice;
	}

	public void setLnkPurchaseInvoice(PurchaseInvoiceDAO lnkPurchaseInvoice) {
		this.lnkPurchaseInvoice = lnkPurchaseInvoice;
	}

	public PurchaseInvoice getPurchaseInvoice() {
		return purchaseInvoice;
	}

	public void setPurchaseInvoice(PurchaseInvoice purchaseInvoice) {
		this.purchaseInvoice = purchaseInvoice;
	}

	

}
